$(function(){
    var renderImg = /partner/ig.test(window.location.pathname);
    var arr = window.location.search.substr(1).split('&');
    var params = {};
    $.each(arr, function(i,v){
        var ky = v.split('=');
        params[ky[0]] = ky[1];
    });
    var lis = $('.tab-wrap li');
    var index = 0;
    switch(params.tab){
        case '1':
            index = 0;
            break;
        case '2':
            index = 1;
            break;
        case '3':
            index = 2;
            break;
        case '4':
            index = 3;
            break;
        default:
            index = 0;
    }
    $('.tab-wrap li').removeClass('tab-active');
    $('.tab-wrap li').eq(index).addClass('tab-active');
    $('.tab-con').removeClass('tab-con-active');
    $('.tab-con').eq(index).addClass('tab-con-active');
    renderImg && addLogo(index);
    $('.tab-wrap li').on('click', function(){
        var idx = $(this).index();
        $('.tab-wrap li').removeClass('tab-active');
        $(this).addClass('tab-active');
        $('.tab-con').removeClass('tab-con-active');
        $('.tab-con').eq(idx).addClass('tab-con-active');
        renderImg && addLogo(idx);
    });

    function addLogo(type){
        var number = 0;
        var path = './img/partner/logo'+(type+1)+'/';
        switch(type){
            case 0:
                number = 24;
            break;
            case 1:
                number = 24;
            break;
            case 2:
                number = 24;
            break;
            default:
        }
        if($('.tab-con-'+(type+1)+' .logo-list li').length <= 0){
            var tpl = [];
            for(var i = 1; i <= number; i++){
                tpl.push('<li><a href="javascript:;"><img src="'+(path+i+'.jpg')+'" alt=""></a></li>');
            }
            $('.tab-con-'+(type+1)+' .logo-list').html(tpl.join(''));
        }
    }

});